from common.Config import EbuyConfig

__author__ = 'yangxianming'



class WhaleApi:
    ebuyConfig = EbuyConfig()

    @staticmethod
    def __update_body(body, update_body="", del_body_key=""):
        if update_body != "":
            body.update(update_body)
        if del_body_key != "":
            if "," in del_body_key:
                for one_key in del_body_key.split(","):
                    del body[one_key]
            else:
                del body[del_body_key]
        return body

    #update_body:{}  del_body_key:key值 使用,分割多个值
    #同步单条发码 MakeCode
    #http://gitbook.docs.e-fuli.com/ebuy-whale-api/cn/api-list/transaction-api/make-code.html
    def get_makecode_data(self, update_body="", del_body_key=""):
        action = "MakeCode"
        default_body = {"saleChannelOrderId":"123","requestId":"12332323232","notifyType":{"mobilePhone":"13524161800"},"item":{"saleChannelItemId":"20181024154201","commissionDate":"1","validDays":10,"ticketId":10000000060209024,"makeFundsChannel":{"channelBenefit":0,"merchantBenefit":500,"userRealAmount":2500}}}
        return action, self.__update_body(body=default_body, update_body=update_body, del_body_key=del_body_key)
        # return {"action":action,"body":self.__update_body(body=default_body, update_body=update_body, del_body_key=del_body_key)}


    def get_funtion_name(self):
        api_list = []
        for one in dir(self):
            if "_data" in one and "get_" in one:
                api_list.append(one[4:-5].replace("_", "."))
        return api_list
